package com.nervenets.general;

import org.apache.poi.sl.usermodel.Notes;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.TextRun;

import java.io.IOException;

/**
 * Created by joe on 2024/3/4.
 */
public class ReadPowerPoint {
    public static void main(String[] args) throws IOException {
        /*// 指定PPT文件路径
        String filePath = "C:\\Users\\Administrator\\Documents\\TestOffice\\test.ppt";

        // 创建SlideShow对象并加载PPT文件
        SlideShow ppt = new HSLFSlideShow(new java.io.FileInputStream(filePath));

        // 获取所有的slide（页）数量
        int numSlides = ppt.getSlides().size();

        System.out.println("Total slides in the PPT: " + numSlides);

        for (int i = 0; i < numSlides; i++) {
            // 获取当前slide
            Slide slide = (Slide) ppt.getSlides().get(i);

            // 输出每张slide中的内容
            Notes notes = slide.getNotes();
            if (notes != null && notes.getTextParagraphs().size() > 0) {
                for (Object run : notes.getTextParagraphs()) {
                    System.out.print(((TextRun) run).getRawText());
                }
            } else {
                System.out.println("No content found on this slide.");
            }

            System.out.println("\n--------------------\n");
        }

        // 关闭PPT文件流
        ppt.close();*/
    }
}
